<?php

class Empeval_BackendController extends Zend_Controller_Action {

  const HOMEPAGE_URL = 'http://vw-group.pl/';

  private $params;

  public function init() {
    if (!$this->getRequest()->isXmlHttpRequest()) {
      $this->_helper->redirector->gotoUrlAndExit(self::HOMEPAGE_URL);
      return;
    }
    $post = $this->getRequest()->getParams();
    $this->params = (array_key_exists('params', $post)) ? new Core_Params($post['params']) : null;
    $this->jsonData();

    if ($this->params->app === null)
      throw new Exception("Object App can't be empty!");

    Empeval_Auth::getInstance();
    Empeval_Core::getInstance()->setApp(new Empeval_Methods_Data_App($this->params->app));
  }

  public function jsonData() {
    $this->_helper->layout->disableLayout();
    $action = $this->getRequest()->getActionName();
    $this->_helper->viewRenderer->setNoRender(true);
    $this->_helper->contextSwitch()
            ->addActionContext($action, 'json')
            ->setAutoJsonSerialization(true)
            ->initContext('json');
    $this->getRequest()->setParam('format', 'json');
  }

  public function checkSessionAction() {
  	$request = new Empeval_Methods_Request_CheckSession($this->params);
  	$this->view->response = $request->process();
  }
  
  public function loginAction() {
    $request = new Empeval_Methods_Request_Login($this->params);
    $this->view->response = $request->process();
  }
  
  public function loginAutoAction() {
  	$request = new Empeval_Methods_Request_LoginAuto($this->params);
  	$this->view->response = $request->process();
  }
  
  public function logoutAction() {
  	$request = new Empeval_Methods_Request_Logout($this->params);
  	$this->view->response = $request->process();
  }
  
  
  public function getMyBonusGoalsAction() {
  	$request = new Empeval_Methods_Request_GetMyBonusGoals($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getBonusGoalsAction() {
  	$request = new Empeval_Methods_Request_GetEmployeeBonusGoals($this->params);
  	$this->view->response = $request->process();
  }
  
  public function removeBonusGoalsFromAction() {
  	$request = new Empeval_Methods_Request_RemoveBonusGoalsFrom($this->params);
  	$this->view->response = $request->process();
  }
  
  public function addBonusGoalsFromAction() {
  	$request = new Empeval_Methods_Request_AddBonusGoalsForm($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getBonusGoalsFromAction() {
  	$request = new Empeval_Methods_Request_GetBonusGoalsForm($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getQualityCriteriasAction() {
  	$request = new Empeval_Methods_Request_GetQualityCriterias($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getBonusPeriodsAction() {
  	$request = new Empeval_Methods_Request_GetBonusPeriods($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getIndicatorsAction() {
  	$request = new Empeval_Methods_Request_GetIndicators($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getSelfAppraisalsAction() {
  	$request = new Empeval_Methods_Request_GetSelfAppraisals($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getBonusGroupsAction() {
  	$request = new Empeval_Methods_Request_GetBonusGroups($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBonusGoalsFormDataAction() {
  	$request = new Empeval_Methods_Request_SetBonusGoalsFromData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBonusGoalsFormPeriodAction() {
  	$request = new Empeval_Methods_Request_SetBonusGoalsFromPeriod($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBonusGoalsFormStatusAction() {
  	$request = new Empeval_Methods_Request_SetBonusGoalsFromStatus($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBonusGoalsForm2StatusAction() {
  	$request = new Empeval_Methods_Request_SetBonusGoalsFrom2Status($this->params);
  	$this->view->response = $request->process();
  }
  
  public function addBonusGoalsFromRowAction() {
  	$request = new Empeval_Methods_Request_AddBonusGoalsFormRow($this->params);
  	$this->view->response = $request->process();
  }
  
  public function removeBonusGoalsFormRowAction() {
  	$request = new Empeval_Methods_Request_RemoveBonusGoalsFormRow($this->params);
  	$this->view->response = $request->process();
  }
  
  public function cancelBonusGoalsFormRowAction() {
  	$request = new Empeval_Methods_Request_CancelBonusGoalsFormRow($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setKpiDataAction() {
  	$request = new Empeval_Methods_Request_SetKpiData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setTaskGoalsDataAction() {
  	$request = new Empeval_Methods_Request_SetTaskGoalsData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setMboDataAction() {
  	$request = new Empeval_Methods_Request_SetMboData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setEvaluationDataAction() {
  	$request = new Empeval_Methods_Request_SetEvaluationData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setSummaryDataAction() {
  	$request = new Empeval_Methods_Request_SetSummaryData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function sendRejectionAction() {
  	$request = new Empeval_Methods_Request_SendRejection($this->params);
  	$this->view->response = $request->process();
  }
  
  public function sendDecisionAction() {
  	$request = new Empeval_Methods_Request_SendDecision($this->params);
  	$this->view->response = $request->process();
  }
  
  public function addEmpevalAction() {
  	$request = new Empeval_Methods_Request_AddEmpeval($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getRejectionsAction() {
  	$request = new Empeval_Methods_Request_GetRejections($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getUsersNameAction() {
  	$request = new Empeval_Methods_Request_GetUsersName($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getPositionsAction() {
  	$request = new Empeval_Methods_Request_GetPositions($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setPositionBonusGroupAction() {
  	$request = new Empeval_Methods_Request_SetPositionBonusGroup($this->params);
  	$this->view->response = $request->process();
  }
  
  public function getMenuDataAction() {
  	$request = new Empeval_Methods_Request_GetMenuData($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBiAction() {
  	$request = new Empeval_Methods_Request_SetBi($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBiActiveAction() {
  	$request = new Empeval_Methods_Request_SetBiActive($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setBiCommentAction() {
  	$request = new Empeval_Methods_Request_SetBiComment($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setEmpevalResultAction() {
  	$request = new Empeval_Methods_Request_SetEmpevalResult($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setSummaryStatusAction() {
  	$request = new Empeval_Methods_Request_SetSummaryStatus($this->params);
  	$this->view->response = $request->process();
  }
  
  public function setEvaluationStatusAction() {
  	$request = new Empeval_Methods_Request_SetEvaluationStatus($this->params);
  	$this->view->response = $request->process();
  }

}